package com.ruoyi.buss.report.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.buss.utils.ListUtil;
import com.ruoyi.common.security.service.TokenService;
import com.ruoyi.system.api.model.LoginUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.report.domain.ReportMarketJxxtLsb;
import com.ruoyi.buss.report.service.IReportMarketJxxtLsbService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 营销业绩统计历史，每天保存4.1.2Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/reportLsb")
public class ReportMarketJxxtLsbController extends BaseController
{
    @Autowired
    private IReportMarketJxxtLsbService reportMarketJxxtLsbService;

    @Autowired
    private TokenService tokenService;

    /**
     * 查询营销业绩统计历史，每天保存4.1.2列表
     * 营销业绩统计表
     */
    @PreAuthorize(hasPermi = "buss:jxxtlsb:list")
    @GetMapping("/yxyjtjb")
    public TableDataInfo yxyjtjb(ReportMarketJxxtLsb reportMarketJxxtLsb)
    {
        reportMarketJxxtLsb.setSjrq(ListUtil.getSjrq(reportMarketJxxtLsb.getSjrq()));
        LoginUser userInfo = tokenService.getLoginUser();

        startPage();
        List<ReportMarketJxxtLsb> list = reportMarketJxxtLsbService.selectReportMarketJxxtLsbList(reportMarketJxxtLsb,userInfo,0);
        return getDataTable(list);
    }



    /**
     * 导出营销业绩统计历史，每天保存4.1.2列表
     */
    @PreAuthorize(hasPermi = "buss:jxxtlsb:exportYxyjtjbService")
    @Log(title = "营销业绩统计历史，每天保存4.1.2", businessType = BusinessType.EXPORT)
    @PostMapping("/exportYxyjtjbService")
    public void export(HttpServletResponse response, ReportMarketJxxtLsb reportMarketJxxtLsb) throws IOException
    {
        reportMarketJxxtLsb.setSjrq(ListUtil.getSjrq(reportMarketJxxtLsb.getSjrq()));
        LoginUser userInfo = tokenService.getLoginUser();

        List<ReportMarketJxxtLsb> list = reportMarketJxxtLsbService.selectReportMarketJxxtLsbList(reportMarketJxxtLsb,userInfo,3);
        ExcelUtil<ReportMarketJxxtLsb> util = new ExcelUtil<ReportMarketJxxtLsb>(ReportMarketJxxtLsb.class);
        util.exportExcel(response, list, "营销业绩统计历史，每天保存4.1.2数据");
    }

}
